<template>
  <div>
    <!-- 表单 -->
    <TopFilter ref="form" :cols="3" :list="list" @filterChange="formChange" @resetChange="resetFun"></TopFilter>
    <!-- 表格 -->
    <el-row style="margin-bottom:10px;">
      <FilterTable
        ref="table"
        height="250"
        columnsRef="partPartOutboundPartSalesQuoteComponentsAddpartSalesQuote"
        :columns="columns"
        :dataSource="dataSource"
        :fetchapi="fetchApi"
        :params="fetchParams"
        :datakey="'rows'"
        selectionType="single"
        :isSelectColumn="false"
        :onEnterEvent="tableDbclickFun"
        :onColumnsChange="columns => (this.columns = columns)"
      >
      </FilterTable>
    </el-row>
    <!-- 表单 -->
    <FormPanel ref="form2" :cols="3" :list="list2" :isSubmitBtn="false" @formChange="formChange2"></FormPanel>
    <!-- 表格 -->
    <FilterTable
      ref="table2"
      columnsRef="partPartOutboundPartSalesQuoteComponentsAddpartSalesQuote1"
      height="auto"
      selectionType="single"
      :columns="columns2"
      :dataSource="dataSource2"
      :onColumnsChange="columns => (this.columns2 = columns)"
    >
    </FilterTable>
    <div class="btnWrap">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="confirmHandle">确 定</el-button>
    </div>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { isAuthorized } from '@/utils/index';
import { getCangKuSelect } from '@/api/part/partOutbound/repairMaterials/dict.js';
import { StockParts, Storage, queryBrand, salesHistory } from '@/api/part/partOut/partSales/index';
import { findAllRepair } from '@/api/repair/basicParameters';
import { getStorageList } from '@/api/part/partOutbound/repairMaterials/dict';
import { getBrand } from '@/api/repair/basicParameters';
import { queryTex } from '@/api/part/common';
export default {
  name: 'partSalesQuote',
  components: {},
  mixins: [dictionary],
  props: {
    cunData: Object,
    rate: String
  },
  data() {
    return {
      listPrice: 0, // 价格  无用
      typePrice: '', // 无用
      fromSubmitdata: {}, // 存表单数据
      flagS: '', // 表单提交控制校验的状态
      listType: [],
      styleList: [], // 样式
      list: this.createList(),
      list2: this.createList2(),
      columns: this.createColumns(),
      columns2: this.createColumns2(),
      dataSource: [],
      dataSource2: [],
      fetchApi: StockParts,
      fetchParams: {
        xhrAbort: true
      },
      initStorage: '',
      useableStock: 0, // 可用库存
      tax: 0 // 税率(计算含税价)
    };
  },
  computed: {
    calculate() {
      return this.list2.find(item => item.fieldName == 'PART_SALES_PRICE').initialValue * this.list2.find(item => item.fieldName == 'PART_QUANTITY').initialValue;
    }
  },
  watch: {
    calculate(newVal, oldVal) {
      this.list2.find(item => item.fieldName == 'SALES_AMOUNT').initialValue = newVal;
    }
  },
  mounted() {
    // this.getCangKuSelect();
    // this.findAllRepair();
    this.getStorage();
    this.queryBrand();
    this.getTax();
  },
  methods: {
    async getTax() {
      if (!this.tax) {
        let res = await queryTex();
        this.tax = res.data;
      }
    },
    tableDbclickFun(val) {
      // 清空上一次的值
      this.styleList = []; // 清空上次定义的样式
      this.dataSource2 = []; // 清空上次的历史查询记录
      this.listRecive = [];
      this.listType = val;
      this.styleList.push({ row: val });
      this.list2.find(item => item.fieldName === 'STORAGE_CODE').initialValue = val.STORAGE_CODE;
      this.list2.find(item => item.fieldName === 'PART_NO').initialValue = val.PART_NO;
      this.list2.find(item => item.fieldName === 'PART_NAME').initialValue = val.PART_NAME;
      this.list2.find(item => item.fieldName === 'PRICE_TYPE').initialValue = this.salesBasePriceType ? this.salesBasePriceType : 80501002;
      this.list2.find(item => item.fieldName === 'PRICE_RATE').initialValue = this.priceAddRate ? this.priceAddRate : 1;
      this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.numFilter(val.SALES_PRICE);
      this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue = 1;
      this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(val.SALES_PRICE);
      this.useableStock = Number(val.USEABLE_STOCK);
      // //第一次默认取的销售价的值
      this.listPrice = this.numFilter(val.SALES_PRICE);
      let data = Object.assign({}, val);
      this.dataSource2 = [data];
      // this.getSalesHistory(val);
    },
    //  async getSalesHistory(val) {
    //   let res = await salesHistory(val.STORAGE_CODE, val.PART_NO, this.customerCode);
    //   this.tablehistory.EXECUTE_INSERT(res.data.rows);
    // },
    // 保留两位小数
    numFilter(value) {
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
    async findAllRepair() {
      const res = await findAllRepair();
      this.initStorage = this.list.find(x => x.fieldName === 'storageCode').initialValue = res.data['1100'];
    },
    // 品牌下拉框
    async queryBrand() {
      // const res = await queryBrand();
      const res = await getBrand();
      this.list.find(item => item.fieldName === 'brand').itemList = res.data.map(x => ({ text: x.BRAND_NAME, value: x.BRAND_CODE + '' }));
      this.list.find(item => item.fieldName === 'brand').initialValue = res.data.find(item => item.BRAND_NAME == '奥迪').BRAND_CODE;
    },
    // 仓库数据
    async getCangKuSelect() {
      const res = await getCangKuSelect();
      this.list.find(x => x.fieldName === 'storageCode').itemList = res.data.map(x => ({ value: x.STORAGE_CODE, text: x.STORAGE_NAME }));
      this.list2.find(x => x.fieldName === 'STORAGE_CODE').itemList = res.data.map(x => ({ value: x.STORAGE_CODE, text: x.STORAGE_NAME }));
      this.columns.find(x => x.dataIndex === 'STORAGE_CODE').editItems = res.data.map(x => ({ value: x.STORAGE_CODE, text: x.STORAGE_NAME }));
    },
    // 改变数量
    changemNum(val) {
      let reg = /^(\-|\+)?([1-9][0-9]*)+(.[0-9]{1,2})?$/;
      let res = String(val).split('.');
      let num = 0;
      if (res[1] != undefined) {
        num = res[1].length;
      }
      if (!reg.test(val) || num > 2) {
        return this.$notify.warning({ title: '提示信息', message: '请输入正确的数值,保留2位小数' });
      } else {
        const money = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue;
        this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(val * money);
      }
    },
    // 添加事件提交表单
    confirmHandle() {
      const nums = this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue;
      this.flagS = false;
      let json = this.dataSource2[0];
      if (this.dataSource2.length == 0) {
        return this.$notify.warning({ title: '提示信息', message: '需选中一条数据' });
      }
      if (this.list2.find(x => x.fieldName == 'SALES_TYPE').initialValue === 80961001) {
        if (json.USEABLE_STOCK - nums < 0) {
          if (json.IS_NEGATIVE == 10041002) {
            return this.$notify.warning({ title: '提示信息', message: '该仓库不允许负库存!' });
          }
        }
      }
      // let reg = /^(\-|\+)?([1-9][0-9]*)+(.[0-9]{1,2})?$/;
      // let res = String(nums).split('.');
      // let num = 0;
      // if (res[1] != undefined) {
      //   num = res[1].length;
      // }
      // if (!reg.test(nums) || num > 2) {
      //   return this.$notify.warning({ title: '提示信息', message: '请输入正确的数值,保留2位小数' });
      // }
      this.$refs.form.SUBMIT_FORM();
      let formdata = Object.assign({}, json, this.fromSubmitdata);
      formdata.SALES_TYPE = formdata.SALES_TYPE ? formdata.SALES_TYPE : 80961002;
      formdata.OUT_QUANTITY = Number(this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue).toFixed(2);
      formdata.OUT_PRICE = Number(this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue).toFixed(2);
      formdata.OUT_AMOUNT = this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue;
      formdata.PRICE_TYPE = this.list2.find(item => item.fieldName === 'PRICE_TYPE').initialValue;
      formdata.PRICE_RATE = this.list2.find(item => item.fieldName === 'PRICE_RATE').initialValue;
      if (formdata.PART_SALES_PRICE < formdata.COST_PRICE) {
        this.$confirm('该配件发料价格低于成本价格，是否继续添加配件？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$emit('confirm', formdata);
        });
      } else {
        this.$emit('confirm', formdata);
      }
    },
    // 改变价格系数参数
    changecoefficient(val) {
      if (this.typePrice == 80501006) {
        // 改变含税金额的值
        const num = this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue;
        let money = this.numFilter(this.listPrice * val); // 参数改变时候，改变金额
        this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = money;
        this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(money * num);
      } else {
        const num = this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue;
        let money = this.numFilter(this.listPrice * val); // 参数改变时候，改变金额
        this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = money;
        this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(money * num);
      }
    },
    // 改变价格类型,每次改变价格类型时候都会对typePrice 和 listPrice 重新赋值用于计算
    changeType(val) {
      // 成本价
      if (val == 80501001) {
        this.typePrice = val;
        // 判断字段是否为空
        if (this.listType.COST_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.COST_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501002) {
        // 销售价
        this.typePrice = val;
        if (this.listType.SALES_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.SALES_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501010) {
        // 索赔价_>含税采购价
        this.typePrice = val;
        if (this.listType.PLAN_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.PLAN_PRICE * (1 + (Number(this.tax) || 0.13));
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501011) {
        this.typePrice = val;
        // 网点价->含税批发价
        if (this.listType.COST_WHOLESALES_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.COST_WHOLESALES_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501005) {
        this.typePrice = val;
        // 最新进货价
        if (this.listType.LATEST_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.LATEST_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501006) {
        // 含税成本价
        this.typePrice = val; // 当时含税成本价对变量赋值，用于金额和参数变动计算
        if (this.listType.COST_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.COST_PRICE + this.listType.COST_PRICE * this.rate;
        } else {
          this.listPrice = 0;
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501007) {
        this.typePrice = val;
        // 终端建议零售价格
        if (this.listType.INSURANCE_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.INSURANCE_PRICE;
        } else {
          this.formList2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }

        this.changeMoney(this.listPrice);
      } else if (val == 80501008) {
        this.typePrice = val;
        // 建议销售价
        if (this.listType.INSTRUCT_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.INSTRUCT_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      } else if (val == 80501009) {
        this.typePrice = val;
        // 销售限价
        if (this.listType.LIMIT_PRICE != null) {
          this.listPrice = this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.listType.LIMIT_PRICE;
        } else {
          this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = 0;
          this.listPrice = 0;
        }
        this.changeMoney(this.listPrice);
      }
    },

    changeMoney(val) {
      if (this.typePrice == 80501006) {
        // 改变含税金额的值
        this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.numFilter(val);
        if (this.listPrice != 0) {
          this.list2.find(item => item.fieldName === 'PRICE_RATE').initialValue = this.numFilter(val / this.listPrice); // 金额改变时候改变参数
        }
        const num = this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue;
        this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(val * num);
      } else {
        this.list2.find(item => item.fieldName === 'PART_SALES_PRICE').initialValue = this.numFilter(val);
        if (this.listPrice != 0) {
          this.list2.find(item => item.fieldName === 'PRICE_RATE').initialValue = this.numFilter(val / this.listPrice); // 金额改变时候改变参数
        }
        const num = this.list2.find(item => item.fieldName === 'PART_QUANTITY').initialValue;
        this.list2.find(item => item.fieldName === 'SALES_AMOUNT').initialValue = this.numFilter(val * num);
      }
    },
    resetFun() {
      // this.$nextTick(() => {
      //   this.list.find(x => x.fieldName == 'storageCode').initialValue = this.initStorage;
      // });
    },
    // 取消的方法
    cancel() {
      this.$emit('cancel');
    },
    // 配件报价单选择 确定方法
    confirmQuotationNumber() {},
    // 点击查询或者重置
    formChange(val) {
      // this.fetchParams.xhrAbort = true;
      this.fetchParams = Object.assign({}, val);
    },
    formChange2(val) {
      this.fromSubmitdata = val;
      this.flagS = true;
    },
    createList() {
      return [
        {
          type: 'SELECT',
          label: '仓库',
          fieldName: 'storageCode',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '品牌',
          fieldName: 'brand',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '配件类别',
          fieldName: 'partGroupCode',
          itemList: this.createDictList('8075')
        },
        // {
        //   type: 'INPUT',
        //   label: '车型组',
        //   fieldName: 'wu4',
        // },
        {
          type: 'INPUT',
          label: '配件代码',
          fieldName: 'PartNo'
        },
        {
          type: 'INPUT',
          label: '配件名称',
          fieldName: 'partName'
        },
        {
          type: 'INPUT',
          label: '拼音代码',
          fieldName: 'spellCode'
        },
        {
          type: 'INPUT',
          label: '库位',
          fieldName: 'storagePositionCode'
        },
        {
          type: 'CHECKBOX',
          label: '库存大于零',
          fieldName: 'stockZero',
          options: {
            trueValue: 10041001,
            falseValue: ''
          }
        },
        {
          type: 'CHECKBOX',
          label: '售价大于零',
          fieldName: 'priceZero',
          options: {
            trueValue: 10041001,
            falseValue: ''
          }
        },
        // {
        //   type: 'INPUT',
        //   label: '中缀名称',
        //   fieldName: 'wu8',
        // },
        {
          type: 'INPUT',
          label: '备注',
          fieldName: 'description'
        }
      ];
    },
    createList2() {
      return [
        {
          type: 'SELECT',
          label: '仓库',
          fieldName: 'STORAGE_CODE',
          itemList: [],
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配件代码',
          fieldName: 'PART_NO',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配件名称',
          fieldName: 'PART_NAME',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '价格类型',
          fieldName: 'PRICE_TYPE',
          disabled: !isAuthorized('1313', '13131010'),
          // 还有方法
          itemList: this.createDictList('8050'),
          change: val => {
            this.changeType(val);
          }
        },
        {
          type: 'INPUT_NUMBER',
          rules: [{ required: true, message: '请输入价格系数', trigger: 'blur' }],
          label: '价格系数',
          min: 0,
          max: 9.99,
          precision: 2,
          fieldName: 'PRICE_RATE',
          change: val => {
            this.changecoefficient(val);
          }
        },
        {
          type: 'INPUT_NUMBER',
          label: '发料单价',
          fieldName: 'PART_SALES_PRICE',
          initialValue: 0,
          precision: 2,
          disabled: !isAuthorized('1313', '13131001'),
          rules: [{ required: true }],
          change: val => {
            this.changeMoney(val);
          }
        },
        {
          type: 'INPUT_NUMBER',
          label: '发料数量',
          fieldName: 'PART_QUANTITY',
          precision: 2,
          min: 0.01,
          initialValue: 1,
          rules: [
            { required: true, message: '请输入发料数量', trigger: 'blur' },
            {
              validator: (rule, value, callback) => {
                // console.log(value, 1, this.saveData);
                if (value > this.useableStock) {
                  // console.log(value);
                  return callback(new Error('发料数量不能大于可用库存数量'));
                } else {
                  callback();
                }
              },
              trigger: ['change', 'blur']
            }
          ],
          change: val => {
            // this.changemNum(val);
          }
        },
        {
          type: 'INPUT',
          label: '发料金额',
          fieldName: 'SALES_AMOUNT',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '销售方式',
          fieldName: 'SALES_TYPE',
          initialValue: 80961001,
          itemList: this.createDictList('8096')
        }
        // {
        //   type: 'INPUT',
        //   label: '备注',
        //   fieldName: 'wu12',
        // },
      ];
    },
    createColumns() {
      return [
        {
          title: '序号',
          width: 50,
          dataIndex: 'xuhao',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '仓库',
          minWidth: 150,
          dataIndex: 'STORAGE_CODE',
          disabled: true,
          editable: false,
          editType: 'select',
          editItems: [],
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '库位',
          dataIndex: 'STORAGE_POSITION_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '配件名称',
          dataIndex: 'PART_NAME',
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '含税销售价',
          dataIndex: 'SALES_PRICE',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        // {
        //   title: '成本价',
        //   dataIndex: 'UNIT_NAME'
        // },
        // {
        //   title: '可用库存',
        //   dataIndex: 'IN_QUANTITY1'
        // },
        {
          title: '账面库存',
          dataIndex: 'STOCK_QUANTITY',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        {
          title: '可用库存',
          dataIndex: 'USEABLE_STOCK',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        //  {
        //   title: '车型组集',
        //   dataIndex: 'IN_QUANTITY3'
        // },
        {
          title: '最新进货价',
          dataIndex: 'LATEST_PRICE',
          sorter: true,
          precision: 2,
          filter: true,
          filterType: 'number'
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
        // {
        //   title: '成本价',
        //   dataIndex: 'COST_PRICE',
        //   sorter: true,
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '网点价',
        //   dataIndex: 'NODE_PRICE',
        //   sorter: true,
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // },
        // {
        //   title: '建议销售价',
        //   dataIndex: 'INSTRUCT_PRICE',
        //   sorter: true,
        //   precision: 2,
        //   filter: true,
        //   filterType: 'number'
        // }
      ];
    },
    createColumns2() {
      return [
        // {
        //   title: '序号',
        //   width: 50,
        //   dataIndex: 'xuhao',
        //   render: props => {
        //         return <span>{props.row.index + 1}</span>;
        //       }
        // },
        // {
        //   title: '销售价',
        //   minWidth: 150,
        //   dataIndex: 'SALES_PRICE',
        // },
        // {
        //   title: '最低销售限价',
        //   minWidth: 120,
        //   dataIndex: 'STORAGE_POSITION_CODE',
        // },
        // {
        //   title: '最高销售限价',
        //   dataIndex: 'LIMIT_PRICE'
        // },
        // {
        //   title: '最高销售限价',
        //   dataIndex: 'PART_NAME'
        // },
        // {
        //   title: '终端建议零售价格',
        //   dataIndex: 'INSURANCE_PRICE'
        // },
        // {
        //   title: '建议销售价',
        //   dataIndex: 'IN_QUANTITY1'
        // },
        //  {
        //   title: '最大库存',
        //   dataIndex: 'IN_QUANTITY2'
        // },
        //  {
        //   title: '最小库存',
        //   dataIndex: 'IN_QUANTITY3'
        // },
        //  {
        //   title: '账面库存',
        //   dataIndex: 'IN_QUANTITY4'
        // },
        //  {
        //   title: '可用库存',
        //   dataIndex: 'IN_QUANTITY5'
        // },
        //  {
        //   title: '借进数量',
        //   dataIndex: 'IN_QUANTITY6'
        // },
        //  {
        //   title: '借出数量',
        //   dataIndex: 'IN_QUANTITY7'
        // },
        //   {
        //   title: '锁定量',
        //   dataIndex: 'LOCKED_QUANTITY'
        // },
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '含税销售价',
          dataIndex: 'SALES_PRICE',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '索赔价',
          dataIndex: 'CLAIM_PRICE',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '终端建议零售价格',
          dataIndex: 'INSURANCE_PRICE',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '销售限价',
          dataIndex: 'LIMIT_PRICE',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '账面库存',
          dataIndex: 'STOCK_QUANTITY',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '可用库存',
          dataIndex: 'USEABLE_STOCK',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '锁定量',
          dataIndex: 'LOCKED_QUANTITY',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '替代配件',
          dataIndex: 'OPTION_NO',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '替代件库存',
          dataIndex: 'OPTION_STOCK',
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        },
        {
          title: '配件类别',
          dataIndex: 'PART_GROUP_CODE',
          sorter: true,
          editable: false,
          editType: 'select',
          editItems: this.createDictList(8075),
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList(8075)
        },
        {
          title: '单位',
          dataIndex: 'UNIT_NAME',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '单位CODE',
          dataIndex: 'UNIT_CODE',
          sorter: true,
          filter: true,
          filterType: 'input',
          hidden: true
        },
        {
          title: '最新进货价',
          dataIndex: 'LATEST_PRICE',
          hidden: true,
          sorter: true,
          filter: true,
          precision: 2,
          filterType: 'number'
        }
      ];
    },

    async getStorage() {
      const res = await getStorageList();
      console.log(res, 'getStorageListressss-----');
      this.list.find(x => x.fieldName === 'storageCode').itemList = res.data.map(x => ({ value: x.STORAGE_CODE, text: x.STORAGE_NAME }));
      console.log(this.list.find(x => x.fieldName === 'storageCode').itemList, 'list----');
      this.list2.find(x => x.fieldName === 'STORAGE_CODE').itemList = this.columns.find(x => x.dataIndex === 'STORAGE_CODE').filterItems = this.columns.find(
        x => x.dataIndex === 'STORAGE_CODE'
      ).editItems = res.data.map(x => ({
        value: x.STORAGE_CODE,
        text: x.STORAGE_NAME
      }));
    }
  }
};
</script>

<style scoped>
.btnWrap {
  position: absolute;
  left: 0px;
  bottom: 0px;
  right: 0px;
  z-index: 9;
  border-top: 1px solid rgb(233, 233, 233);
  padding: 10px 20px;
  background: rgb(255, 255, 255);
  text-align: right;
}
</style>
